package com.test.controller;


import com.test.dao.UserDao;
import com.test.pojo.User;
import org.beetl.sql.core.SQLManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/*
*注意新版本中 UserDao 不可通过 Autowired
* 来注入使用
* 必须通过getMapper 来反射代理
* */

@Controller
@RequestMapping("/mapper")
public class MapperController {

    Logger logger= LoggerFactory.getLogger(MyController.class);

    @Autowired
    public SQLManager sqlmanager;


  /*  @RequestMapping(value = "body")
    @ResponseBody
    public List<User> getBody(){
        UserDao userDao = sqlmanager.getMapper(UserDao.class);
        List<User> list = userDao.select2("xian");
        return list;

    }*/


    @RequestMapping(value = "body2")
    @ResponseBody
    public User getBody2(){
        UserDao userDao = sqlmanager.getMapper(UserDao.class);

        //通过参数查询
        User byId = userDao.findById(1);

        return byId;

    }


    @RequestMapping(value = "body3")
    @ResponseBody
    public User getBody3(){
        UserDao userDao = sqlmanager.getMapper(UserDao.class);
        User user = userDao.findByName("张三");




        return user;

    }


}
